package ch.axon.demo.managedbean;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;

import ch.axon.demo.entity.Book;
import ch.axon.demo.stateless.BookDao;

@ManagedBean(name = "bookmanager")
@RequestScoped
public class BookManager {
	@EJB
	private BookDao bookDao;
	private String bookName;
	public String getBookName() {
		return bookName;
	}
	public void setBookName(String bookName) {
		this.bookName = bookName;
	}
	
	public void addBook(ActionEvent e) {
		System.out.println("bookname = " + this.bookName);
		bookDao.addBook(this.getBookName());
		System.out.println(bookDao.getBooks().toString());
	}
	
	public List<Book> getBooks() {
		return bookDao.getBooks();
	}
	
	
}
